import request from '../../utils/request';
import {download} from '../../utils/commons'
const R=require("ramda");
/**
 * 查询客户信息
 * @param lesseesCode
 * @param beginTime
 * @param endTime
 * @param page
 */
export async function getCustomerList({beginTime, endTime,status, page}) {
    return request(apiPath.zbtim + "/api/report/customer",
        {
            method: 'get',
            data: { beginTime: beginTime, endTime: endTime,status:status, page: page.page, size: page.size}
        });
}


/**
 * 导出客户信息
 * @param lesseesCode
 * @param beginTime
 * @param endTime
 */
export async function exportCustomerList({beginTime, endTime,status}) {
    let url =  apiPath.zbtim + "/api/report/customer/export";
    let data={};
    beginTime=R.isNil(beginTime)?'':beginTime;
    endTime=R.isNil(endTime)?'':endTime;
    status=R.isNil(status)?'':status;
    data={beginDate: beginTime, endDate: endTime,status:status, filename: '客户信息表'}
    download(url, data);
}


/**
 * 查询客户对账单
 * @param cstId
 * @param beginTime
 * @param endTime
 * @param status
 * @param page
 * @returns {Promise<*>}
 */
export async function getReconciliationList({cstId, beginTime, endTime, contractNo, page}) {
    return request(apiPath.zbtim + "/api/report/" + cstId + "/statementdetail",
        {
            method: 'get',
            data: {beginTime, endTime, contractNo, page: page.page, size: page.size}
        });
}

/**
 * 导出客户对账单
 * @param cstId
 * @param beginTime
 * @param endTime
 */
export async function getDZD({cstId, beginTime, endTime}) {
    let url =  apiPath.zbtim + "/api/report/cstbill/export";
    let data={};
    cstId=R.isNil(cstId)?'':cstId;
    beginTime=R.isNil(beginTime)?'':beginTime;
    endTime=R.isNil(endTime)?'':endTime;

    data={cstId: cstId, beginTime: beginTime, endTime: endTime, filename: '客户对账单'}
    download(url, data);
}


/**
 * 导出客户结算详情表
 * @param cstId
 * @param beginTime
 * @param endTime
 * @param cstName
 * @returns {Promise<void>}
 */
export async function exporReconciliationList({cstId, contractNo, beginTime, endTime, cstName}) {
    let url = apiPath.zbtim + "/api/report/" + cstId + "/statementdetail/export";
    let data = {};
    beginTime = R.isNil(beginTime) ? '' : beginTime;
    endTime = R.isNil(endTime) ? '' : endTime;
    cstName = R.isNil(cstName) ? '' : cstName;
    data = {cstId, beginTime, endTime, cstName, filename: '客户结算详情表_新'}
    download(url, data);
}

/**
 * 查询客户订单账目明细
 * @param cstId
 * @param beginTime
 * @param endTime
 * @param status
 * @param page
 * @returns {Promise<*>}
 */
export async function getOrderBilldetailList({cstId, beginTime, endTime, contractNo, page}) {
    return request(apiPath.zbtim + "/api/report/" + cstId + "/orderbilldetail",
        {
            method: 'get',
            data: {beginTime, endTime, contractNo, page: page.page, size: page.size}
        });
}


/**
 * 导出客户订单账目明细
 * @param cstId
 * @param beginTime
 * @param endTime
 * @param cstName
 * @returns {Promise<void>}
 */
export async function exporOrderBilldetailList({cstId, beginTime, endTime, cstName}) {
    let url = apiPath.zbtim + "/api/report/" + cstId + "/orderbilldetail/export";
    let data = {};
    beginTime = R.isNil(beginTime) ? '' : beginTime;
    endTime = R.isNil(endTime) ? '' : endTime;
    cstName = R.isNil(cstName) ? '' : cstName;
    data = {beginTime, endTime, cstName, filename: '客户订单账目表'}
    download(url, data);
}